import 'package:flutter/material.dart';
import 'package:flutter_09_game/config/app_language.dart';
import 'package:flutter_09_game/generated/assets.dart';
import 'package:flutter_09_game/generated/locales.g.dart';
import 'package:flutter_09_game/widgets/image/auto_image.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../../config/app_color.dart';

class CustomBottomNavigation extends StatelessWidget {
  final int currentIndex;
  final Function(int) onTap;

  const CustomBottomNavigation({
    super.key,
    required this.currentIndex,
    required this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      height: kBottomNavigationBarHeight + ScreenUtil().bottomBarHeight,
      decoration: const BoxDecoration(
        color: AppColor.navBarBackground,
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          // HomePage(),
          // PromotionPage(),
          // DepositPage(),
          // WelfarePage(),
          // ProfilePage(),
          _buildNavItem(
              0, LocaleKeys.navHome.tr, Assets.navHome, Assets.navHomeS),
          _buildNavItem(1, LocaleKeys.navPromotion.tr, Assets.navPromotion,
              Assets.navPromotionSel),
          _buildNavItem(2, LocaleKeys.navDeposit.tr, Assets.navDeposit,
              Assets.navDepositSel),
          _buildNavItem(3, LocaleKeys.navWelfare.tr, Assets.navWelfare,
              Assets.navWelfareSel),
          _buildNavItem(4, LocaleKeys.navProfile.tr, Assets.navProfile,
              Assets.navProfileSel),
        ],
      ),
    );
  }

  Widget _buildNavItem(int index, String title, String icon, String iconSel) {
    final isSelected = currentIndex == index;

    return GestureDetector(
      onTap: () => onTap(index),
      child: Container(
        width: 75.w,
        // height: 60.w,
        decoration: BoxDecoration(
          gradient: isSelected
              ? LinearGradient(
                  begin: Alignment.topCenter,
                  end: Alignment.bottomCenter,
                  colors: [
                    AppColor.primary.withOpacity(0.3),
                    Colors.transparent,
                  ],
                )
              : null,
          border: Border(
            top: BorderSide(
              color: isSelected ? AppColor.primary : Colors.transparent,
              width: 2,
            ),
          ),
        ),
        child: Column(
          // mainAxisAlignment: MainAxisAlignment.center,
          children: [
            6.verticalSpaceFromWidth,
            AutoImage(
              isSelected ? iconSel : icon,
              width: 24.w,
              height: 24.w,
              // child: icon,
            ),
            4.verticalSpace,
            Text(
              title,
              style: TextStyle(
                fontSize: 12.sp,
                fontWeight: isSelected ? FontWeight.w600 : FontWeight.w500,
                color:
                    isSelected ? AppColor.primary : AppColor.navBarUnselected,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
